/*
 *@description:版本目录接口
 *@author: wudandan
 *@date: 2020-09-23 13:48:07
*/
import axios from './request';

/*
 *@functionName: getEditionInfo
 *@description:查询用户可用的教材
 *@author: wudandan
 *@date: 2020-09-23 13:52:16
*/
export async function getEditionInfo () {
  const { data } = await axios.get(`${process.env.VUE_APP_UC_URL}/isch-c/user/book`);
  return data;
}
/*
 *@functionName: getUsedEdition
 *@description:查询用户最新访问的教材ID
 *@author: wudandan
 *@date: 2020-09-23 13:54:43
*/
export async function getUsedEdition () {
  const { data } = await axios.get(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/last`);
  return data;
}
/*
 *@functionName: updateUseEdition
  *@params1: bookId
 *@description: 更新用户最新访问的教材ID
 *@author: wudandan
 *@date: 2020-09-23 13:56:38
*/
export async function updateUseEdition (bookId) {
  const { data } = await axios.post(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/last/${bookId}`);
  return data;
}
/*
 *@functionName: getUsedCatalog
  *@params1: bookId
 *@description:查询用户教材目录进度
 *@author: wudandan
 *@date: 2020-09-23 13:59:02
*/
export async function getUsedCatalog (bookId) {
  const { data } = await axios.get(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/progress/${bookId}`);
  return data;
}
/*
 *@functionName: updateUseCatalog
 *@params1: bookId
 *@params2: catalogId
 *@description:更新用户教材目录进度
 *@author: wudandan
 *@date: 2020-09-23 14:00:51
*/
export async function updateUseCatalog (bookId, catalogId) {
  const { data } = await axios.post(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/progress/${bookId}/${catalogId}`);
  return data;
}
/*
 *@functionName: getUserSetEdition
 *@description:查询用户设置的教材
 *@author: wudandan
 *@date: 2020-09-23 14:50:44
*/
export async function getUserSetEdition () {
  const { data } = await axios.get(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/set`);
  return data;
}
/*
 *@functionName: setUseEdition
 *@params1: bookId
 *@description:用户教材设置
 *@author: wudandan
 *@date: 2020-09-23 14:52:21
*/
export async function setUseEdition (bookId) {
  const { data } = await axios.post(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/set/${bookId}`);
  return data;
}
/*
 *@functionName: deleteUseEdition
 *@params1: bookId
 *@description:用户教材删除
 *@author: wudandan
 *@date: 2020-09-23 14:54:58
*/
export async function deleteUseEdition (bookId) {
  const { data } = await axios.delete(`${process.env.VUE_APP_UC_URL}/isch-c/user/book/set/${bookId}`);
  return data;
}
/*
 *@functionName: getCatalogInfoByCode
 *@params1: studyStageCode
 *@params2: subjectCode
 *@params3: versionCode
 *@description:查询教材
 *@author: wudandan
 *@date: 2020-09-23 16:53:11
*/
export async function getCatalogInfoByCode (studyStageCode, subjectCode, versionCode) {
  const { data } = await axios.get(
    `${process.env.VUE_APP_UC_URL}/isch-c/user/book/${studyStageCode}/${subjectCode}/${versionCode}`
  );
  return data;
}
/*
 *@functionName: getSecSubjVer
 *@description:学段学科版本
 *@author: wudandan
 *@date: 2020-09-23 16:55:15
*/
export async function getSecSubjVer () {
  const { data } = await axios.get(`${process.env.VUE_APP_UC_URL}/isch-c/user/stages/subjects/versions`);
  return data;
}
/*
 *@functionName: getCatalogTree
 *@description:教材获取课程、课时
 *@author: wudandan
 *@date: 2020-09-23 15:06:51
*/
export async function getCatalogTree ({ bookId, type }) {
  const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/rms/v1/catalogue/list_cata_logue`, {
    params: { bookId, type }
  });
  return data;
}
/*
 *@functionName: getDirectoryTree
 *@description:根据年级、学期、学科、版本查询专题目录
 *@author: wudandan
 *@date: 2020-09-23 16:59:49
*/
export async function getDirectoryTree ({ tagValues }) {
  const { data } = await axios.post(`${process.env.VUE_APP_NRMS_URL}/rms/catalogue/directory_tree`, {
    tagValues,
    type: 2,
    level: 1
  });
  return data;
}

export async function getListRecordByids ({ catIds }) {
  const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/rms/v1/catalogue/list_record_by_ids`, {
    params: { catIds }
  });
  return data;
}
